﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using log4net;
using System.Diagnostics;
using StockFinder.Services.Engines;
using StockFinder.StockLists.Indexes;
using StockFinder.StockLists;
using StockFinder.Model.Enumerations;

namespace StockFinder.Consoles.PricesDownloader
{
    class Program
    {
        private static readonly ILog _Log = LogManager.GetLogger(typeof(Program));

        static void Main(string[] args)
        {
            List<string> symbolsList = new List<string>();

            /* GET SYMBOLS UNIVERSE */

            var stockLists = new List<IStockList>{
                new TelegraphOnlineFtse100StockList(){ LoadPrices = false},
                new TelegraphOnlineFtse250StockList(){ LoadPrices = false}
            };

            string name = string.Empty;

            foreach (var stockList in stockLists)
            {
                foreach (var symbol in stockList)
                {
                    name = symbol.Name;

                    if (symbol.Exchange == Exchange.LONDON)
                    {
                        name += ".L";
                    }

                    if (!symbolsList.Contains(name))
                    {
                        symbolsList.Add(name);
                    }
                }
            }            

            /* RUN PRICE HISTORY DATABASE UPDATER */

            DailyPricesHistoryDatabaseUpdater priceDatabaseUpdater = new DailyPricesHistoryDatabaseUpdater();
            priceDatabaseUpdater.Run(symbolsList, false); 
        }
    }
}
